package com.cuijq.ms.statedesign.v4;

/**
 * @author by CuiJQ
 * @Classname MarioStateMachine
 * @Description MarioStateMachine Description
 * @Date 2021/5/29 15:18
 *
 * MarioStateMachine 和各个状态类之间是双向依赖关系。MarioStateMachine 依赖各个状态类是理所当然的，
 * 但是，反过来，各个状态类为什么要依赖 MarioStateMachine 呢？
 * 这是因为，各个状态类需要更新 MarioStateMachine 中的两个变量，score 和 currentState
 *
 */
public class MarioStateMachine {

  private int score;
  private IMario currentState;

  public void obtainMushRoom() {
    this.currentState.obtainMushRoom();
  }

  public void obtainCape() {
    this.currentState.obtainCape();
  }

  public void obtainFireFlower() {
    this.currentState.obtainFireFlower();
  }

  public void meetMonster() {
    this.currentState.meetMonster();
  }

  public int getScore() {
    return this.score;
  }

  public State getCurrentState() {
    return this.currentState.getName();
  }

  public void setScore(int score) {
    this.score = score;
  }

  public void setCurrentState(IMario currentState) {
    this.currentState = currentState;
  }
}
